import os
import re

class ip_utils:
	ip = ""
	pattern = r'inet\s(?P<ip>(\d+?\.)+\d)'

	@staticmethod
	def Get_windows_ip():
		ip = os.popen("ipconfig").read() ## Win 
		return ip  
	@staticmethod
	def Get_freeBSD_ip():
		ip = os.popen('ifconfig').read() ##
		return ip

	@staticmethod
	def get_ip():
		ip = ip_utils.Get_windows_ip()
		#print len(ip)
		if len(ip) == 0:
			ip = ip_utils.Get_freeBSD_ip()
		#	print ip
		ip = re.findall(ip_utils.pattern,ip)#.group("ip")
		print ip


if __name__ == "__main__":
	ip = ip_utils.get_ip()